package org.xiaoyu.boot.stater.shiro;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

import javax.servlet.Filter;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = ShiroProperties.SHIRO_PREFIX)
public class ShiroProperties {

	public static final String SHIRO_PREFIX = "shiro";
	/**
	 * 登录地址
	 */
	private String loginUrl = "login.jsp";

	/**
	 * 成功登录跳转地址
	 */
	private String successUrl = "index.jsp";

	/**
	 * 无权限时跳转地址
	 */
	private String unauthorizedUrl = "403.jsp";

	/**
	 * 拦截器
	 */
	private Map<String, Filter> filters = new HashMap<>();;

	/**
	 * 拦截地址,通过key进行升序排列,例:filterChainDefinitionOrderMap.put(1,'login=anon')
	 */
	private TreeMap<Integer, String> filterChainDefinitionOrderMap;
	

	/**
	 * shiro拦截地址
	 */
	private String filterUrl;
	
	/**
	 * shiro拦截地址配置文件
	 */
	private String filterChainDefinitionResourcePath;
	
	/**
	 * 是否开启权限注解,默认false
	 */
	private Boolean openPermissionsAnnotation = false;
	
	
	public String getLoginUrl() {
		return loginUrl;
	}

	public void setLoginUrl(String loginUrl) {
		this.loginUrl = loginUrl;
	}

	public String getSuccessUrl() {
		return successUrl;
	}

	public void setSuccessUrl(String successUrl) {
		this.successUrl = successUrl;
	}

	public String getUnauthorizedUrl() {
		return unauthorizedUrl;
	}

	public void setUnauthorizedUrl(String unauthorizedUrl) {
		this.unauthorizedUrl = unauthorizedUrl;
	}

	public Map<String, Filter> getFilters() {
		return filters;
	}

	public void setFilters(Map<String, Filter> filters) {
		this.filters = filters;
	}

	public String getFilterUrl() {
		return filterUrl;
	}

	public void setFilterUrl(String filterUrl) {
		this.filterUrl = filterUrl;
	}

	public String getFilterChainDefinitionResourcePath() {
		return filterChainDefinitionResourcePath;
	}

	public void setFilterChainDefinitionResourcePath(String filterChainDefinitionResourcePath) {
		this.filterChainDefinitionResourcePath = filterChainDefinitionResourcePath;
	}
	public TreeMap<Integer, String> getFilterChainDefinitionOrderMap() {
		return filterChainDefinitionOrderMap;
	}

	public void setFilterChainDefinitionOrderMap(TreeMap<Integer, String> filterChainDefinitionOrderMap) {
		this.filterChainDefinitionOrderMap = filterChainDefinitionOrderMap;
	}

	public Boolean getOpenPermissionsAnnotation() {
		return openPermissionsAnnotation;
	}

	public void setOpenPermissionsAnnotation(Boolean openPermissionsAnnotation) {
		this.openPermissionsAnnotation = openPermissionsAnnotation;
	}
	

}
